<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//登录控制器
class DengluController extends Controller{
	
	private $Model;
	//构造函数
	public function __init(){
		$this->Model = new \Common\Model\Home_user;
	}
	
	
//登录页面
	public function index(){
//		p($_SERVER);
//		p(md5('home'));
//		p($_POST);
		if(IS_POST){
			
			$name = Q('post.home_name');
			$passwodr = Q('post.home_passwodr','','md5');
//			p($name);exit;
			$homeus = $this->Model->where("home_name='{$name}'")->find();
			
			
//			p($homeus);exit;
			
			if($homeus['home_name'] != $name){
				
				View::error('用户不存在');
			}
			 if($homeus['home_passwodr'] != $passwodr){
				
				View::error('密码错误');
			}
			  if($homeus['home_name'] == $name && $homeus['home_passwodr'] == $passwodr){
			  	
				$_SESSION['home_uid'] = $homeus['home_uid'];
				 $_SESSION['home_name'] = $name;
//				p($_SESSION);exit;  
//               $_SERVER['REQUEST_URI']  跳转的是点击前一次浏览的地址
				View::success('登录成功',U('Index/index'));
			}
			
		}
//		$q = $this->Model->find();
//		
//		p($q);
		

		View::make();
	}
	
	
	
}
